import os
import re
from SqlDB import myDB

def subdirname(realpath:str,dirname):
    res=realpath
    splitcharlist=['/','\\']
    for c in splitcharlist:
        if realpath.startswith(dirname+c):
            res=realpath.replace(dirname+c,'')
    return res


if __name__ == '__main__':
    objdb=myDB('learn.db')
    allist=objdb.query_r("SELECT * FROM source",())
    for i in allist:
        mid=i[0]
        print(mid)
        path=i[1]
        path=subdirname(path,'source')
        objdb.update('source',['path'],['mid'],(path,mid))